<?php

// @formatter:off
/**
 * @file WCComicsHolder.php
 * @author Alejandro Dario Simi
 * @date $Date: 2014-05-04 01:33:52 +0000 (Sun, 04 May 2014) $
 *
 * $Id: WCComicsHolder.php 111 2014-05-04 01:33:52Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/includes/holders/WCComicsHolder.php $
 */
// @formatter:on

/**
 * @class WCComicsHolder
 * This class is a holder for representations of table '%comics', in other
 * words, a holder for WCComic objects.
 */
class WCComicsHolder extends WCHolderGroup implements WCSearchIndexableHolder {
	/**
	 * @var string Class name of the objects to be held.
	 */
	protected $_PropertiesItemClass = "WCComic";
	/**
	 * @var string This is the prefix of every column on the table
	 * '%comics'.
	 */
	protected $_PropertiesPrefix = "cmc_";
	/**
	 * @var string This is the name of the table represented by WCComic
	 * objects. In this case, '%comics'.
	 */
	protected $_PropertiesTable = "comics";
	//
	// Public methods.
	public function notIndexedId() {
		$out = array();
		//
		// Creating the statement to select non indexed tags.
		// @{
		$stmt = null;
		$stmtId = __CLASS__."::".__FUNCTION__."[{$this->_PropertiesTable}]";
		if($this->_db->has($stmtId)) {
			$stmt = $this->_db->get($stmtId);
		} else {
			$query = "select  {$this->_PropertiesPrefix}id as id\n";
			$query .= "from    {$this->_dbprefix}{$this->_PropertiesTable}\n";
			$query .= "where   {$this->_PropertiesPrefix}indexed = 'N'\n";
			$query .= " and    {$this->_PropertiesPrefix}lost    = 'N'\n";

			$stmt = $this->_db->prepare($stmtId, $query);
		}
		// @}

		if($stmt->execute() && $stmt->rowCount() > 0) {
			foreach($stmt->fetchAll() as $row) {
				$out[] = $row["id"];
			}
		}

		return $out;
	}
	public function searchItemsType() {
		return "CX";
	}
}
